﻿using System;
using System.Globalization;
using System.Windows.Data;
using FitnessHelperDB;

namespace FitnessHelperDesktopClient
{
  /// <summary>
  /// Служит для отображения количества продукта в порции
  /// </summary>
  [ValueConversion(typeof(FoodPortions), typeof(string))]
  class FoodAmountConverter : IValueConverter
  {
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
      var foodPortion = value as FoodPortions;

      if (foodPortion == null ||
          foodPortion.Id == 0)
      {
        return null;
      }

      return string.Format("{0} * {1}", foodPortion.Amount, foodPortion.Foods.FoodUnits.Name);
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
      throw new NotImplementedException();
    }
  }
}
